import {myRequest} from '@/utils/api.js'

export const CRMURL = '/admin';

export function apiLogin(data) {
	let action = data.action || '';
	let postdata = data.params || '';
	switch (action) {
		case 'login':
			return myRequest(CRMURL + '/api.Login/login', postdata)
			break;
		case 'logout':
			return myRequest(CRMURL + '/api.Login/logout', postdata)
			break;
		case 'get_config_data':
			return myRequest(CRMURL + '/api.Login/get_config_data', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

export function apiSysAuth(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'sys_auth_access':
			return myRequest(CRMURL + '/api.SysAuth/sys_auth_access')
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//系统消息
export function apiSysMsg(data) {

	let action = data.action || '';
	let postdata = data.params || '';

	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SysMsg/show_json', postdata)
			break;
		case 'set_deal':
			return myRequest(CRMURL + '/api.SysMsg/set_deal', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SysMsg/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//系统用户消息
export function apiSysNotifyUser(data) {

	let action = data.action || '';
	let postdata = data.params || '';
	switch (action) {
		case 'get_list':
			return myRequest(CRMURL + '/api.SysNotifyUser/show_json', postdata)
			break;
		case 'set_read':
			return myRequest(CRMURL + '/api.SysNotifyUser/set_read', postdata)
			break;
		case 'del':
			return myRequest(CRMURL + '/api.SysNotifyUser/del', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//系统配置数据
export function apiSysConfig(data) {

	let action = data.action || '';
	let postdata = data.params || '';
	switch (action) {
		case 'get_conf_data':
			return myRequest(CRMURL + '/api.SysConfig/get_conf_data', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//系统用户数据
export function apiSysUser(data) {

	let action = data.action || '';
	let postdata = data.params || '';
	switch (action) {
		case 'get_sys_user_sons':
			return myRequest(CRMURL + '/api.SysUser/get_sys_user_sons', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}

//系统部门数据
export function apiSysDept(data) {

	let action = data.action || '';
	let postdata = data.params || '';
	switch (action) {
		case 'get_list_tree':
			return myRequest(CRMURL + '/api.SysDept/get_list_tree', postdata)
			break;
		default:
			let text = "期待周末！";
			return Promise.resolve(text);
	}
}